﻿// AmiEventMessage.cs
// Copyright © 2013 Alex Forster

namespace Ami
{
	using System;
	using System.Diagnostics.Contracts;

	public sealed class AmiEventMessage: AmiMessage
	{
		public new static MessageConverter Converter;

		static AmiEventMessage()
		{
			AmiEventMessage.Converter = AmiEventMessage.EventConverter;
		}

		private static AmiMessage EventConverter( AmiMessage message )
		{
			Contract.Assert( message != null );

			if( message["Event"] == null )
			{
				return null;
			}

			var result = new AmiEventMessage();

			result.Headers = message.Headers;

			result.Received = DateTime.UtcNow;

			return result;
		}

		public String Event
		{
			get { return this["Event"]; }
		}
	}
}
